10 REM Simple Sequence Demo for STOS Basic 100 REM 1000 REM will have NO effect since they are only used to initialise. You MUST 1010 REM STOP the current sequence, re-poke the values, then call Go again. 1020 REM 1030 REM Now REPLAY the sequence Once 1040 REM 1050 LOKE 1060 VARNAME 1070 VARNAME 1080 CALL 1090 REM 110 RESERVE 1100 REM 4 commands start the sequence (ALL MODE, not using sep. mix) 1110 REM The commands below wait for it to stop. 1120 REM and check for a key press 1130 REM 1140 PRINT 1150 WAIT 1160 WHILE 1170 PRINT 1180 VARNAME 1190 IF 120 RESERVE 1200 WEND 1210 WAIT 1220 REM 1230 REM Now PLAY the other mix 5 Times 1240 REM It IS IMPORTANT that the previous sequence was Halted before the next 1250 REM sequence begins !!!!! 1260 REM 1270 LOKE 1280 VARNAME 1290 VARNAME 130 REM 1300 CALL 1310 REM 1320 REM Anothermix is sent the address of the mix 1330 REM And C_down is set to loop 5 times 1340 REM 1350 PRINT 1360 PRINT 1370 PRINT 1380 WAIT 1390 WHILE 140 REM In order to save using more banks for the separate mixes 1400 PRINT 1410 VARNAME 1420 IF 1430 WEND 1440 REM 1450 REM Now REPLAY the sequence (normal) - Infinite Loops 1460 REM 1470 LOKE 1480 VARNAME 1490 VARNAME 150 REM It is easier to just use an array. Dimension the array to the 1500 CALL 1510 REM 1520 REM C_down=0 ; This sets looping to infinite ! 1530 REM loke => Go back to using the (ALL of) Sequence mix 1540 REM wait for a key to stop 1550 REM 1560 PRINT 1570 WAIT 1580 VARNAME 1590 WHILE 160 REM Desktop size in bytes of the mix file. 1600 VARNAME 1610 WEND 1620 CALL 1625 VARNAME 1630 REM 1640 REM First Loke ANOTHERMIX with the address of your mix, or zero if you 1650 REM want to play the mix in your sequence file. 1660 REM Then set FINISH to a positive value other than zero. Usually 1. 1670 REM Set the C_DOWN (count down) variable to the number of plays required 1680 REM Or to zero for infinite looping. 1690 REM Call the GO routine.The sequence is now happily running under interupt 170 REM 1700 REM (all on its own). If you want to just let it run then put the rest of 1710 REM your program after the call. Your program will run while the sequence 1720 REM is running.If you wish to stop the sequence at any time just call HALT 1730 REM This will disable the interupt and stop the seq. 1732 REM You should also set FINISH to zero - although this isn't necessary 1733 REM it may be of use to you, having a flag which is zero when no seq. 1734 REM is playing. NOTE FINISH is automatically set to zero when all loops 1735 REM have been played !!! and it holds the sequencial number of the next 1736 REM sample it was to play if you stop the seq. with HALT. 1740 REM If you want to know when the seq. is finished then check the value of 1750 REM FINISH if it is zero the seq. is finished (all loops have been done). 1760 REM FINISH is set to one every time the first sample is being played. 1770 REM A Final Note : 1780 REM DO NOT CHANGE OR REMOVE EITHER THE SEQUENCE OR THE CODE WHILE A SEQ. 1790 REM IS PLAYING. THIS WILL CRASH THE ATARI. YOU MUST CALL Halt BEFORE DOING 180 DIM 1800 REM THIS. ALSO DO NOT START ANOTHER SEQUENCE WHILE A SEQUENCE IS PLAYING 1810 REM THIS WILL CREATE TWO INTERUPTS, THE FIRST OF WHICH CAN NOT BE REMOVED 1820 REM BY Halt AND PROBABLY CRASH THE MACHINE. 1830 REM YOU MUST ALSO NOT TERMINATE YOUR PROGRAM WHILE A SEQUENCE IS 1840 REM PLAYING, UNLESS YOU MAKE THE CODE AND SEQ. STAY RESIDENT. SO BEFORE 1850 REM TERMINATING YOUR PROGRAM CHECK THAT A SEQUENCE IS NOT PLAYING, OR JUST 1860 REM CALL Halt TO BE SAFE. 1870 REM 1880 REM ONE FINAL IMPORTANT WARNING - IF YOUR PROGRAM STOPS, BECAUSE OF 1890 REM A SYNTAX ERROR (OR ANY ERROR) OR IF YOU BREAK INTO IT BEFORE 190 REM 1900 REM IT TERMINATES ITSELF (WHEN IN THE EDITOR) CALL Halt JUST TO BE SURE. 1910 REM BECAUSE THE SEQUENCE WILL KEEP PLAYING WHILE YOU EDIT THE PROGRAM 1920 REM AND IF YOU TRY TO RUN YOUR PROGRAM AGAIN (OR THE ARRAYS/BANKS GET 1930 REM ALTERED IN ANY WAY) THE MACHINE WILL EVENTUALLY CRASH !!! 1940 REM -- IT'S PROBABLY BEST IF YOU PUT THE MUSIC IN AFTER YOU'VE 1950 REM WRITTEN AND TESTED YOUR PROGRAM SINCE SWITCHING OF THE INTERRUPT 1960 REM EVERYTIME YOU BREAK INTO YOUR PROGRAM CAN BE A REAL BIND -- 1970 REM HAVE FUN - THATS ALL FOLKS ! 1980 REM 1990 PRINT 20 REM by I.Hancock- PHAZE Shift Inc. 200 REM Load machine code 2000 PRINT 2010 ERASE 2020 END 210 REM 220 PRINT 230 LOAD 240 REM 250 REM Assign variables to point to the start addresses of the banks/arrays 260 REM 270 VARNAME 280 VARNAME 290 VARNAME 30 REM 300 VARNAME 310 VARNAME 320 REM 330 REM Code and Sequence and Mix are the relevent start addresses. 340 REM Finish is a variable passed to the machine code routine. It is 350 REM incremented every time a sample is played from the sequence or mix and 360 REM set to zero when the sequence or mix finish (after all loops). 370 REM C_down is another passed variable. It counts down each loop. 380 REM 390 REM Define CALL addresses 40 REM Reserve banks for code & sequence (& if wanted alternate mixes) 400 REM 410 VARNAME 420 VARNAME 430 REM 440 REM Go and Halt are the start addresses of the machine code routines. 445 REM Note: DO NOT call HALT before calling PLAY at least ONCE !!! 450 REM 460 REM Define storage offsets 470 REM 480 VARNAME 490 VARNAME 50 REM & allocate addresses for each. Bk 9 should be dimensiond to the desktop 500 VARNAME 510 VARNAME 520 REM 530 REM Seqstart is the address to which you must write the start address of 540 REM the sequence. You MUST always have a sequence even if you only use the 550 REM mixes. Since the .SEQ file contains the samples to be used by the mix. 560 REM .MIX files only contain the order of play information, this is why they 570 REM are alot smaller. Using a MIX file which is not correct for the current 580 REM sequence may CRASH the computer. To be sure a MIX file will work with a 590 REM sequence:- load the sequence into my sequencing program, then load 60 REM size in bytes of your sequence file. You can have as many alternative 600 REM the MIX file. If the MIX file loads then it IS OK. 610 REM Fin is the address to which you must write the address of your Finish 620 REM flag.: Ever is the address to which your must write the address of your 630 REM C_down variable.(count down) mode. 640 REM Anothermix is the address to which must write the start address of 650 REM a separate mix. 660 REM 670 REM Load sequence and mix into memory 680 REM 690 PRINT 70 REM mixes as you like and should dimension each array to DT size in bytes. 700 BLOAD 710 PRINT 720 BLOAD 730 REM 740 REM Poke Sequence data into code 750 REM 760 LOKE 770 LOKE 780 LOKE 790 LOKE 80 REM Bank 8 is the Machine Code to play the sequence and MUST be included. 800 REM 810 REM The 1st Loke puts the start address of the sequence into the Machine - 820 REM -code.The second puts the address of your Finish flag variable into MC 830 REM The MC will count Finish up each time it plays another sample from the 840 REM sequence/mix. It is finally set to zero when the seq/mix has finished. 850 REM It is set to 1 at the start of each loop and NEVER goes to zero when in 860 REM infinite loop mode.(for obvious reasons - it never finishes! 870 REM The third Loke puts the address of your C_down (count down) variable 880 REM into the MC. The MC will count C_down down to zero - when the looping 890 REM will stop. You can change the value of either of the prev. 2 variables 90 REM These banks/arrays are where you will load the files into memory. 900 REM HOWEVER if Finish counts above $FFFFFFFF it will reset to zero which 910 REM your program may see as sequence finished ! NOTE: setting Finish to 0 920 REM will NOT stop the sequence. The MC ONLY counts Finish for your benefit 930 REM If you set C_down to zero during or before a sequence is playing then 940 REM infinite mode is engaged. In the same way setting it to 1 will make it 950 REM stop at the end of the current loop. Since the MC treats both variables 960 REM un-signed, using negative no.s will be equivalent to using V. High 970 REM no.s. (I don't advise using negative no.s !!) 980 REM The final Loke tells the MC to use (all of) the sequence and not a 990 REM mix. Changing either the 1st or last Loke while a sequence is playing